﻿@model QuanLyGiaoVuUI.Models.GiangVienClient.DeTaiGiangVienClientViewModel

@{
    ViewBag.Title = "DeTai";
    Layout = "~/Views/Shared/_GiangVienClientLayout.cshtml";
}
<pages validaterequest="false" />
<style>
    #quanlydetai-left {

    }
</style>
<div id="gv-main-wrapper">
    @{Html.RenderPartial("GiangVienClientGiangDayMenuPartial");}

    <div id="main" class="grid_10 gvclientmain">
        <!--  start page-heading -->

        <div id="page-heading" class="box round first grid">
            <h2>Đề Tài Năm Học @Model.namHoc.Nam1 - @Model.namHoc.Nam2</h2>
            <!-- end page-heading -->

            <div id="gvclientmaincontent" class="block">                
                <div id="quanlydetai-left">
                    <table class="data display datatable">
                        <tr>
                            <th class="sorting">STT</th>
                            <th class="sorting">Tên đề tài</th>
                            <th class="sorting">Tiến độ</th>
                            <th class="sorting">Mô tả</th>
                            <th class="sorting">Đủ đk bảo vệ</th>
                            @*<th class="table-header-options line-left"></th>*@
                        </tr>
                        @{var count = 0; var stt = 0;}
                        @foreach (var detai in Model.deTaiGiangVien)
                        {
                            <tr class="gradeA @(++count % 2 == 0 ? "even" : "odd")">
                                <td class="odd gradeX">@(++stt)</td>
                                <td class="odd gradeX">@detai.TenDeTai</td>
                                <td><a class="xemtiendo" href="#" rel="@detai.MaDeTai" data="@detai.TenDeTai">Xem tiến độ</a></td>
                                <td class="odd gradeX">@Html.Raw(detai.MoTa)</td>
                                <td class="odd gradeX"><a class="xacnhandt" rel="@detai.MaDeTai" aria-valuetext="@detai.KhoaLuanTotNghiep">@((detai.KhoaLuanTotNghiep==1?"Đã XN": "Chưa XN"))</a></td>
                                @*<td class="odd gradeX"><a class="xoadt" rel="@detai.MaDeTai">[X]</a></td>*@
                            </tr>
                        }
                    </table>
                </div>
                <br />
                <br />
                <br />
                <div id="quanlydetai-bottom">
                    <div><h2>Tiến độ đề tài: <span id="quanly-tendetai"></span></h2></div>
                    <div><input type="hidden" id="currentID" value="" /></div>
                    <div id="quanlytiendo-main">

                    </div>  
                                                                             
                </div>
            </div>
        </div>
    </div>

    <div class="clear">&nbsp;</div>

</div>


<script type="text/javascript" src="@Url.Content("~/Content/js/jsToastMessage/javascript/jquery.toastmessage.js")"></script>
@*<div style="background:gray;" id="dangKyTienDoDeTaiDialog"></div>*@

    <script>
        $(document).ready(function () {
            $(".xacnhandt").click(function () {
                var madetai = $(this).attr("rel");
                var khoaluan = $(this).attr("aria-valuetext");
                //alert("madetai:" + madetai + "<>" + khoaluan);
                if (madetai == null || madetai == "") {
                    return;
                }
                else {
                    //alert(madetai);
                    $.post("/GiangVienClient/XacNhanDeTai", { maDeTai: madetai, khoaLuan:khoaluan }, function (data) {
                        if (data.success == true) {
                            ThongBao(data);                            
                            //window.location = "/GiangVienClient/QuanLyTienDoDeTai";
                        }
                        else {
                            ThongBao(data);                            
                        }
                    });
                }
            });
            $('.xoadt').click(function () {
                var madetai = $(this).attr("rel");
                //alert(madetai);
                if (madetai == null || madetai == "") {
                    return;
                }
                else {
                    //alert(madetai);
                    $.post("/GiangVienClient/XoaDeTai", { MaDeTai: madetai }, function (data) {
                        if (data.success == true) {
                            alert("Xóa thành công!");
                            //window.location = "/GiangVienClient/Detai";
                        }
                        else {
                            alert("Thao tác không thành công!");
                        }
                    });
                }
            });
            

            //$("#dangKyTienDoDeTaiDialog").dialog({
            //    autoOpen: false, modal: true, width: 500, height: "auto", title: "Thêm tiến độ đề tài",
            //    buttons: {
            //        "Thêm": function () {
            //            $("#btnDangKyTienDoDeTai").click();
            //        },
            //        "Hủy": function () {
            //            $("#dangKyTienDoDeTaiDialog").dialog("close");
            //        }
            //    }
            //});
            
            $('.xemtiendo').click(function () {
                var madetai = $(this).attr("rel");                
                var tendetai = $(this).attr("data");
                $('#quanly-tendetai').html(tendetai);
                $("#currentID").val(madetai);
                //alert(madetai);
                $("#quanlytiendo-main").load("/GiangVienClient/TienDoDeTai/" + madetai);                
            });

            //$('#themtiendo').click(function () {
            //    var madetai = $("#madetai2").val();
            //    //alert(madetai);
            //    $("#dangKyTienDoDeTaiDialog").load("/giangvienclient/addtiendodetai/" + madetai);
            //    $("#dangKyTienDoDeTaiDialog").dialog("open");
            //});
            
        });
        function DangKyThanhCong(data) {
            if (data.message != null)
                alert(data.message);
            if (data.success == true) {
                $("#dangKyTienDoDeTaiDialog").dialog("close");
            }
            window.location = "/SinhVien/XemDeTaiDangKy";
        }
        function ThongBao(data) {
            if (data.success)
                {
                ToastManager.showSuccessToast("Cập nhật thành công.");
                window.setTimeout("refreshPage", 3000);
                setTimeout(function () {
                    refreshPage();
                }, 3000);
            }
            else {
                ToastManager.showStickyWarningToast(data.message);
            }
        }
        function refreshPage() {
            window.location = "/GiangVienClient/QuanLyTienDoDeTai";
        }
    </script>

